package io.scnb.lesson001.demo5;

import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DiTest {
    @Test
    public void diByConstructorParamIndex() {
        String beanXml = "classpath:/io/scnb/lesson001/demo5/diByConstructorParamIndex.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        System.out.println(context.getBean("diByConstructorParamIndex"));
    }

    @Test
    public void diByConstructorParamType() {
        String beanXml = "classpath:/io/scnb/lesson001/demo5/diByConstructorParamType.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        System.out.println(context.getBean("diByConstructorParamType"));
    }

    @Test
    public void diByConstructorParamName() {
        String beanXml = "classpath:/io/scnb/lesson001/demo5/diByConstructorParamName.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        System.out.println(context.getBean("diByConstructorParamName"));
    }

    @Test
    public void diBySetter() {
        String beanXml = "classpath:/io/scnb/lesson001/demo5/diBySetter.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        System.out.println(context.getBean("diBySetter"));
    }

    @Test
    public void diBean() {
        String beanXml = "classpath:/io/scnb/lesson001/demo5/diBean.xml";
        ClassPathXmlApplicationContext context = IocUtils.context(beanXml);
        System.out.println(context.getBean("diBeanByConstructor"));
        System.out.println(context.getBean("diBeanBySetter"));
    }
}
